
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct person{//person structure
    char first[100];//first name
    char last[100];//last name
    int marked;//if the person has been used already
};



struct person scan(){//scans for the information of the person
    struct person man;
    
    printf("input first name\n");
    scanf("%s",man.first);//scans first name
    printf("input last name\n");
    scanf("%s",man.last);//scans last name
    man.marked = 0;//sets this person to unused
    
    return(man);//returns the information of the person
}

int main(int argc, const char * argv[])
{
    struct person listofpeople[17];//the list of people
    struct person randlistofpeople[17];//the scrambled list of people
    
    for(int i =0;i <= 17;i++){//scans 18 people
        
        listofpeople[i] = scan();//scans a person
        
        printf("%s %s has been marked for death. \n \n", listofpeople[i].first, listofpeople[i].last);
        
    }
    
    for(int i = 0;i <= 17; i++){//randomizes the list
        int test = rand() % 18;
        while(listofpeople[test].marked == 1){//makes sure that the new slot is not taken
            test = rand() % 18;
        }
        listofpeople[test].marked = 1;//marks the scrambled person so that they would not be used again
        randlistofpeople[i] = listofpeople[test];//sets the new position of the person
    }
    
    for(int i =0;i <= 17;i++){
        
        if (i == 17) {//loops the list to complete the circle
            printf("%s %s's target is: %s %s \n", randlistofpeople[i].first, randlistofpeople[i].last, randlistofpeople[0].first, randlistofpeople[0].last);
        }else {
            printf("%s %s's target is: %s %s \n", randlistofpeople[i].first, randlistofpeople[i].last, randlistofpeople[i+1].first, randlistofpeople[i+1].last);
        }
    }

    return 0;
}
